<h1>Editing role</h1>

<% form_for(@role) do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :description %><br />
    <%= f.text_field :description %>
  </p>
      <p><%= '权限信息'  %><br />
    <%Permission.all.each do |permission|%>
     <%= check_box_tag "role[permission_ids][]", permission.id, @role.permissions.include?(permission) %>
    <%= permission.name %>
  <%end%>
    <p><%= User.human_name  %><br />
    <%User.all.each do |user|%>
     <%= check_box_tag "role[user_ids][]", user.id, @role.users.include?(user) %>
    <%= user.name %>
  <%end%>
 </p>
  <p>
    <%= f.submit 'Update' %>
  </p>
<% end %>

<%= link_to 'Show', @role %> |
<%= link_to 'Back', roles_path %>